package com.jcl.recruit.resume.service;

import com.jcl.recruit.resume.logic.ResumeLogic;
import com.jcl.recruit.resume.model.Resume;
import com.jcl.recruit.user.mapper.UserOtherjobMapper;
import com.jcl.recruit.user.model.UserOtherjob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 刘明新
 * @date 2018/8/3 下午2:49
 */
@Service
public class ResumeBaseService {
    @Autowired
    private ResumeLogic resumeLogic;

    @Autowired
    private UserOtherjobMapper userOtherjobMapper;


    public List<Map<String, Object>> selectQueryResumes(String keyword,
                                                        String education,
                                                        String sex,
                                                        Integer workyear,
                                                        String city,
                                                        Date dateBegin,
                                                        Date dateEnd,
                                                        String sourceSub,
                                                        Integer status,
                                                        Integer userId,
                                                        Integer ismanual) {
        List<Map<String, Object>> list = resumeLogic.selectQueryResumes(keyword, education, sex, workyear,
                city, dateBegin, dateEnd, sourceSub, status, userId, ismanual);
        return list;
    }

    public List<Map<String, Object>> selectCountResume(String keyword,
                                                       String education,
                                                       String sex,
                                                       Integer workyear,
                                                       String city,
                                                       Date dateBegin,
                                                       Date dateEnd,
                                                       String sourceSub,
                                                       Integer status,
                                                       Integer userId,
                                                       Integer ismanual) {
        return resumeLogic.selectCountResume(keyword, education, sex, workyear,
                city, dateBegin, dateEnd, sourceSub, status, userId, ismanual);
    }

    /*public Map<String, Object> selectResumeByPrimsryKeyIdMap(Integer id) {

        String corpCode = RequestUtils.getCorpCode();

        Map<String, Object> map = new HashMap<>();
        map = resumeLogic.selectResumeByPrimsryKeyIdMap(id);
        if(map.get("tags") != null) {
            map.put("tags", CommonService.splitString(map.get("tags").toString(), ","));
        }
        Integer age = null;
        if(map.get("birthday") != null) {
            age = DateUtils.formatAge(map.get("birthday").toString());
        }
        map.put("age",age);
        List<Map<String, Object>> edus = resumeEduLogic.findObjListByResumeId(corpCode, id);
        List<Map<String, Object>> works = resumeWorkLogic.findObjListByResumeId(corpCode,id);
        List<Map<String, Object>> projects = resumeProjectLogic.findObjListByResumeId(corpCode,id);
        if(CollectionUtils.isEmpty(edus)){
            edus = new ArrayList<>();
        }
        if(CollectionUtils.isEmpty(works)){
            works = new ArrayList<>();
        }
        if(CollectionUtils.isEmpty(projects)){
            projects = new ArrayList<>();
        }
        map.put("edus",edus);
        map.put("works",works);
        map.put("projects",projects);
        return map;
    }*/

    public List<Map<String, Object>> selectAttentionResumesByCondition(List<Integer> resumeIds) {
        return resumeLogic.selectAttentionResumesByCondition(resumeIds);
    }

    public int insert(Resume resume) {
        int result = resumeLogic.insert(resume);
        return result;
    }

    public Resume countNameAndMobile(String realname, String mobile) {
        return resumeLogic.countNameAndMobile(realname, mobile);
    }

    public int updateByPrimaryKeySelective(Resume record) {
        return resumeLogic.updateByPrimaryKeySelective(record);
    }

    public Map<String, Object> selectPrimaryKey(Integer id) {
        return resumeLogic.selectResumeByPrimsryKeyIdMap(id);
    }

    public int batchUpdate(List<Resume> list) {
        return resumeLogic.batchUpdate(list);
    }

    public int insertOtherjob(UserOtherjob userOtherjob) {
        return userOtherjobMapper.insert(userOtherjob);
    }

    public Resume selectPrimarykeyByEntity(Integer id) {
        return resumeLogic.selectPrimarykeyByEntity(id);
    }

}

